﻿package com.wandian.view.components.ui
{
	import com.wandian.data.GameData;

	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.external.ExternalInterface;
	import flash.text.TextField;
	import flash.text.TextFormat;

	public class LoadingPanelImpl extends Sprite
	{

		public var _mcLoading:LoadingPanel;
		public var _logo:Bitmap;
		private var fmt:TextFormat;

		public function LoadingPanelImpl()
		{
//			var _class:Class=Class(LoadingPanel);
//			this._mcLoading=new _class();
			this._mcLoading=new LoadingPanel;
//			this._mcLoading.x=this._mcLoading.y=0;
			addChild(this._mcLoading);
			GameData.stopMcAllChild(this._mcLoading);
			this.goto(0);
			this._mcLoading.reload_btn.addEventListener(MouseEvent.CLICK, this.linkTxtHandler);
			var _class1:Class=Class(LogoClass);
			this._logo=new Bitmap(new _class1());
//			Texas.I._mcWindosView.centerXY(_logo);
			//change pixel
			if (GameData.is800)
			{
				this._mcLoading.x=0; //(Texas.I.stage.stageWidth-this._mcLoading.width)*0.5;
				this._mcLoading.y=0; //(Texas.I.stage.stageHeight-this._mcLoading.height)*0.5;
				_logo.x=262.5;
				_logo.y=130;
			}
			else
			{
				this._mcLoading.x=Texas.I.stage.stageWidth / 2;
				this._mcLoading.y=Texas.I.stage.stageHeight / 2;
				_logo.x=201;
				_logo.y=100;
			}


			addChild(this._logo);
//			trace(_logo.x+","+_logo.y+" w:"+_logo.width+" h:"+_logo.height);
//			trace(_mcLoading.x+","+_mcLoading.y+" w:"+_mcLoading.width+" h:"+_mcLoading.height);
			this._mcLoading.tip_txt.addEventListener(TextEvent.LINK, this.linkTxtHandler);
//			this._mcLoading.num_mc.txt.visible=false;
//			this._mcLoading.loading_mc.visible=false;
//			this._mcLoading.num_mc.txt.text = "aaaa";
			return;
		}

//		var count:int=0;

		public function goto(pecent:int):void
		{
//			this._mcLoading.num_mc.txt.text=count++;
//			trace(pecent);
//			this._mcLoading.num_mc.txt.text = "loading :100%";
//			this._mcLoading.num_mc.txt.setTextFormat(fmt);
			this._mcLoading.num_mc.txt.text="loading : " + pecent + "%";
			this._mcLoading.loading_mc.gotoAndStop(pecent);
			return;
		}

		public function showGameTip():void
		{
			this._mcLoading.gameTip_txt.htmlText=GameData.tip["GAME_LOAD_TIP"];
			return;
		}

		public function showTip(param1:String):void
		{
			this._mcLoading.tip_txt.htmlText=param1 + "<a href=\"event:1\"><u>" + GameData.tip["GET_USER_INFO_ERR_2"] + "</u></a>";
			return;
		}

		private function linkTxtHandler(param1):void
		{
			ExternalInterface.call("window.location.reload");
			return;
		}

	}
}
